#encoding='gbk'

import unittest
from selenium import webdriver
import time


class Test(unittest.TestCase):
    def setUp(self):
        self.driver= webdriver.Chrome(executable_path='D:\\pythonglr\\python\\driver\\chromedriver.exe')
        pass
    def testSoGou(self):
        self.driver.get('http://sogou.com')
        self.driver.find_element_by_id('query').send_keys(u'WebDriver实战宝典')
        self.driver.find_element_by_id('stb').click()
        time.sleep(3)
        assert u'测试' in self.driver.page_source,u'页面中农不存在要寻找的关键字'.encode('gbk')
        pass
    def testBaidu(self):
        self.driver.get('https://www.baidu.com')
        self.driver.find_element_by_id('kw').clear()
        self.driver.find_element_by_id('kw').send_keys(u'WebDriver实战宝典')
        time.sleep(1)
        self.driver.find_element_by_id('su').click()
        time.sleep(3)
        assert u'' in self.driver.page_source,u'页面中不存在要查找的关键字'.encode('gbk')
        pass
    def tesrDown(self):
        self.driver.quit()

if __name__=='__main__':
    unittest.main()